﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace HitachiService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的接口名“IService1”。
    [ServiceContract]
    public interface IHitachiService
    {
        [OperationContract]
        ProjectData GetProjectById(int id);

        [OperationContract]
        List<ProjectData> GetProjectsByParentId(int parent_id);

        [OperationContract]
        List<ProjectData> GetProjectsByResourceId(int resource_id);

        [OperationContract]
        List<ProjectData> GetProjectsByLevel(int level);

        [OperationContract]
        ResourceData GetResourceById(int id);

        [OperationContract]
        List<ResourceData> GetResourcesByParentId(int parent_id);

        [OperationContract]
        ResourceData GetResourceByUserPswd(String username, String password);

        [OperationContract]
        void DeleteScheduleById(int id);

        [OperationContract]
        void SaveSchedule(ScheduleData data);

        [OperationContract]
        void FreezeScheduleByProjectId(int project_id, int action_type);

        [OperationContract]
        void FreezeSchedule(ScheduleData data);

        [OperationContract]
        List<ScheduleData> GetScheduleByProject(int project_id);

        [OperationContract]
        List<ScheduleData> GetSchedulesByParentProject(int parent_project_id);

        [OperationContract]
        SchedulePolicyData GetSchedulePolicyByProjectId(int project_id);

        [OperationContract]
        void SaveSchedulePolicy(SchedulePolicyData data);

        // New API
        [OperationContract]
        WholeLineData GetWholeLineData(int project_id);

        [OperationContract]
        String GetScheduleDoc(int week_id, int line_id);
    }


    [DataContract]
    public class BaseData
    {
        private int id;
        private int parent_id;

        [DataMember]
        public int ID
        {
            get { return id; }
            set { id = value; }
        }

        [DataMember]
        public int ParentID
        {
            get { return parent_id; }
            set { parent_id = value; }
        }
    }

    [DataContract]
    public class ProjectData : BaseData
    {
        private int level;
        private String name;
        private int action_date;
        private int action_time;
        private String dev_id;
        private String custom_name;
        private String custom_type;
        private String dev_floor;
        private String floor_type;
        private String contract_type;

        [DataMember]
        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        [DataMember]
        public String Name
        {
            get { return name; }
            set { name = value; }
        }

        [DataMember]
        public int ActionDate
        {
            get { return action_date; }
            set { action_date = value; }
        }

        [DataMember]
        public int ActionTime
        {
            get { return action_time; }
            set { action_time = value; }
        }

        [DataMember]
        public String DevID
        {
            get { return dev_id; }
            set { dev_id = value; }
        }

        [DataMember]
        public String CustomName
        {
            get { return custom_name; }
            set { custom_name = value; }
        }
        [DataMember]
        public String CustomType
        {
            get { return custom_type; }
            set { custom_type = value; }
        }
        [DataMember]
        public String DevFloor
        {
            get { return dev_floor; }
            set { dev_floor = value; }
        }
        [DataMember]
        public String FloorType
        {
            get { return floor_type; }
            set { floor_type = value; }
        }
        [DataMember]
        public String ContractType
        {
            get { return contract_type; }
            set { contract_type = value; }
        }
    }

    [DataContract]
    public class ResourceData : BaseData
    {
        private int level;
        private String name;
        private int access;
        private String username;
        private String password;
        private String work_id;
        private String work_title;
        private String work_level;

        [DataMember]
        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        [DataMember]
        public String Name
        {
            get { return name; }
            set { name = value; }
        }

        [DataMember]
        public int Access
        {
            get { return access; }
            set { access = value; }
        }

        [DataMember]
        public String Username
        {
            get { return username; }
            set { username = value; }
        }
        [DataMember]
        public String Password
        {
            get { return password; }
            set { password = value; }
        }
        [DataMember]
        public String WorkID
        {
            get { return work_id; }
            set { work_id = value; }
        }
        [DataMember]
        public String WorkTitle
        {
            get { return work_title; }
            set { work_title = value; }
        }
        [DataMember]
        public String WorkLevel
        {
            get { return work_level; }
            set { work_level = value; }
        }
    }

    [DataContract]
    public class ScheduleData : BaseData
    {
        private int start_time;
        private int end_time;
        private int action_date;
        private int action_time;
        private int project_id;
        private int resource_id;
        private int action_type;
        private int freezed;

        [DataMember]
        public int StartTime
        {
            get { return start_time; }
            set { start_time = value; }
        }
        [DataMember]
        public int EndTime
        {
            get { return end_time; }
            set { end_time = value; }
        }
        [DataMember]
        public int ActionDate
        {
            get { return action_date; }
            set { action_date = value; }
        }
        [DataMember]
        public int ActionTime
        {
            get { return action_time; }
            set { action_time = value; }
        }
        [DataMember]
        public int ProjectId
        {
            get { return project_id; }
            set { project_id = value; }
        }
        [DataMember]
        public int ResourceId
        {
            get { return resource_id; }
            set { resource_id = value; }
        }
        [DataMember]
        public int ActionType
        {
            get { return action_type; }
            set { action_type = value; }
        }
        [DataMember]
        public int Freezed
        {
            get { return freezed; }
            set { freezed = value; }
        }
    }

    [DataContract]
    public class SchedulePolicyData : BaseData
    {
        private int project_id;
        private int mask;

        [DataMember]
        public int ProjectId
        {
            get { return project_id; }
            set { project_id = value; }
        }
        [DataMember]
        public int Mask
        {
            get { return mask; }
            set { mask = value; }
        }
    }

    [DataContract]
    public class WholeLineData
    {
        private List<ProjectData> projects;
        private List<ResourceData> resource;
        private List<ScheduleData> schedules;
        private SchedulePolicyData schedule_policy;

        [DataMember]
        public List<ProjectData> Projects
        {
            get { return projects; }
            set { projects = value; }
        }
        [DataMember]
        public List<ResourceData> Resources
        {
            get { return resource; }
            set { resource = value; }
        }
        [DataMember]
        public List<ScheduleData> Schedules
        {
            get { return schedules; }
            set { schedules = value; }
        }
        [DataMember]
        public SchedulePolicyData SchedulePolicy
        {
            get { return schedule_policy; }
            set { schedule_policy = value; }
        }
    }
}
